(function() {
	const paramStr = location.search
	console.log(paramStr)
	const params = new URLSearchParams(paramStr)
	params.forEach(async (value, key) => {
		if (key === 'keyword') {
			// console.log(key, value)
			var keywords = value + ",柴垛"
			var metaEl = document.querySelector('meta[name="keywords"]');
			metaEl.setAttribute('content', keywords);

			var titleEl = document.querySelector('title');
			titleEl.innerHTML = value + '-柴垛'
			
			var description = "柴垛（www.chaiduo.com）为您搜索的"+value+"找到了相应的"+value+"内容资讯。"
			var metaElDesc = document.querySelector('meta[name="description"]');
			metaElDesc.setAttribute('content', description);
			// metaElDesc.content=description

			document.querySelector('.recTitle span').innerHTML = value
			const res = await axios({
				url: `cdArticle/getSearchArticleList`,
				method: 'post',
				data: {
					keyword: value,
					pageNo: 1,
					pageSize: 10
				}
			})
			// console.log(res.data.result.list)
			const list = res.data.result.list
			const str = list.map(item => {
				return `
				<a href='./article.html?aId=${item.id}'>
					<li data-id=${item.id}>
						<h3>${item.title}</h3>
						<div class="center">
							<img src="${item.coverImg}" alt="" title=${item.title}>
							<p>${item.descript}
							</p>
						</div>
						<div class="details">
							<span>${item.createTime}</span>
							<div class="point"></div>
							<span>${item.brands[0].bname}</span>
							<div class="point"></div>
							<span>${item.homeCategory}</span>
							<div class="point"></div>
							<span>${item.readNum}阅读</span>
						</div>
					</li>
				</a>`
			}).join('')
			document.querySelector('.result ul').innerHTML = str
		}

	})
})();